﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebService.Connect;
using System.Data.SqlClient;
using Model;
using System.Data;

namespace WebService.Datalayer
{
    public class DBBookingDetails
    {

        Database db = new Database();
        SqlParameter[] listParameter;

        /// <summary>
        /// SelectBookingDetailsAll
        /// </summary>
        /// <returns></returns>
        public DataSet SelectBookingDetailsAll()
        {
            return db.GetDataset("sp_SelectBookingDetailsAll");
        }

        /// <summary>
        /// SelectBookingDetailsByAndBookingDetailID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public DataSet SelectBookingDetailsByAndBookingDetailID(BookingDetails obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@BookingDetailID",obj.BookingDetailID),
            };
            return db.GetDataSetWithParameter("sp_SelectBookingDetailsByAndBookingDetailID", listParameter);
        }

        /// <summary>
        /// DeleteBookingDetail
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int DeleteBookingDetail(int obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@BookingID", obj),
            };
            return db.ExcuteQueryWithParamater("sp_DeleteBookingDetail", listParameter);
        }

        /// <summary>
        /// SelectBookingDetailByBookingID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public DataSet SelectBookingDetailsByBookingID(int BookingID)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@BookingID", BookingID),
            };

            return db.GetDataSetWithParameter("sp_SelectBookingDetailsByAndBookingID", listParameter);
        }

        /// <summary>
        /// SelectBookingDetailsByMenuID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public DataSet SelectBookingDetailsByMenuID(BookingDetails obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuID",obj.MenuID),
            };
            return db.GetDataSetWithParameter("sp_SelectBookingDetailsByAndMenuID",listParameter);
        }
        
        /// <summary>
        /// InsertBookingDetail
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int InsertBookingDetail(BookingDetails obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@BookingDetailID",obj.BookingDetailID),
                new SqlParameter("@BookingID", obj.BookingID),
                new SqlParameter("@MenuID", obj.MenuID),
                new SqlParameter("@Status", obj.Status),
                new SqlParameter("@Price", obj.Price),
                new SqlParameter("@Quantity", obj.Quantity),
                new SqlParameter("@IsDeleted", obj.IsDeleted),
            };
            return db.ExcuteQueryWithParamater("sp_InsertBookingDetail", listParameter);
        }

        /// <summary>
        /// UpdateBookingDetail
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int UpdateBookingDetail(BookingDetails obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@BookingID", obj.BookingID),
                new SqlParameter("@MenuID", obj.MenuID),
                new SqlParameter("@Status", obj.Status),
                new SqlParameter("@Price", obj.Price),
                new SqlParameter("@Quantity", obj.Quantity),
                new SqlParameter("@IsDeleted", obj.IsDeleted),
                new SqlParameter("@BookingDetailID", obj.BookingDetailID),
            };
            return db.ExcuteQueryWithParamater("sp_UpdateBookingDetail", listParameter);
        }
    }
}